<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*
        1.如何改变promise的状态
           1)resolve(value):如果当前是pending就会变成resolved
           2)reject(reason):如果当前是pending就会变成rejected
           3)抛出异常：如果当前是pending就会成rejected
           
        2.一个promise指定多个成功/失败回调函数，都会调用吗
          当promise改变为对应的状态时都会调用

         */
        let p = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve(1)
                // throw 6
                //这里抛啥，失败里面的reason就是啥
            }, 1000)
        })
        p.then(
            values => console.log('成功的回调用了1', values),
            reason => console.log('失败的回调用了2', reason),
        )
        p.then(
            values => console.log('成功的回调用了1', values),
            reason => console.log('失败的回调用了2', reason),
        )
        p.then(
            values => console.log('成功的回调用了1', values),
            reason => console.log('失败的回调用了2', reason),
        )
        p.then(
            values => console.log('成功的回调用了1', values),
            reason => console.log('失败的回调用了2', reason),
        )
    </script>
</body>

</html>